package com.woniu.p2p.behindServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.p2p.behindService.MyCompanyService;
import com.woniu.p2p.entity.CompanyMincompany;
import com.woniu.p2p.entity.InvestCompany;
import com.woniu.p2p.mapper.CompanyMincompanyMapper;
import com.woniu.p2p.mapper.InvestCompanyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MyCompanyServiceImpl implements MyCompanyService {

    @Autowired
    InvestCompanyMapper investCompanyMapper;
    @Autowired
    CompanyMincompanyMapper companyMincompanyMapper;


    @Override
    public PageInfo<InvestCompany> findAllInvestCompany(Integer start, Integer num, String companystatus, Date predate, Date nextdate, String companykeyword) {
        PageHelper.startPage(start,num);
        List<InvestCompany> list = investCompanyMapper.findAllInvestCompany(companystatus, predate, nextdate, companykeyword);
        PageInfo<InvestCompany> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public List<InvestCompany> findAllInvestCompany(int[] id) {
        List<InvestCompany> list = investCompanyMapper.findAllInvestCompanyById(id);
        return list;
    }

    @Override
    public List<CompanyMincompany> findAllMinCompany(int id) {
        return companyMincompanyMapper.findAllMinCom(id);
    }

    @Override
    public int insertCompany(InvestCompany investCompany) {
        return investCompanyMapper.insert(investCompany);
    }

    @Override
    public int deleteCompanyById(int id) {
        return investCompanyMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<InvestCompany> selectAll() {
        return investCompanyMapper.selectAll();
    }
}
